package week4.num.ExceptionDemo01.utilityTest;

public class SchoolPeople {
    //私有化创建变量记录学生个人id
    private String id;
    //私有化创建变量记录学生个人姓名
    private String sname;
    //私有化创建变量记录学生个人姓名
    private String sage;
    //创建schoolPeople类的空参构造

    public SchoolPeople() {
    }

    //创建schoolPeople类的全参构造


    public SchoolPeople(String id, String sname, String sage) {
        this.id = id;
        this.sname = sname;
        this.sage = sage;
    }

    //为私有化变量id和name创建get和set方法
    public String getSage() {
        return sage;
    }

    public void setSage(String sage) {
        this.sage = sage;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    //创建方法实现年龄自动增长
    public void aging() {
        //将字符串类型转化为int类型
        int i = Integer.parseInt(sage);
        //年龄加一
        i++;
        //将int转String并赋值
        this.sage = Integer.toString(i);

    }
}
